<%--
  Created by IntelliJ IDEA.
  User: WYX
  Date: 2024/4/12
  Time: 12:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" import="java.util.LinkedList" %>
<jsp:useBean id="word" class="experimentReport.bean.Five" scope="application"/>
<html>
<head>
    <title>实验五：成语接龙</title>
    <style>
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
        }
    </style>
</head>
<body>
<form>
    <label>
        接龙:<input type="text" name="rear">
        <input type="submit" name="submit" value="提交"><br>
        <%String rear = request.getParameter("rear");
            if (rear != null) {
                out.print("结果:" + word.play(rear));
                if (!word.getList().isEmpty()) {
                    int n = word.getList().size();
                    LinkedList<String> list = word.getList();
                    out.print("<table><tr><th>序号</th><th>成语</th></tr>");
                    for (int i = n - 1; i >= 0; i--)
                        out.print("<tr><td>" + (i + 1) + "</td><td>" + list.get(i) + "</td></tr>");
                    out.print("</table>");
                }
            }%>
    </label>
</form>
</body>
</html>
